package GUI;
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JPanel;

import Controller.OneTimeOrderInAdvance;
import Controller.SubscriptionOrder;

import GUI.SubscriptionOrderGui;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import java.awt.Font;
/**
 * this is the GUI of the customer. he can chose to order a new subscriptions, take new complaints and view his orders. 
 * @author Or Marx
 *
 */
public class MainGui extends JPanel{
	JFrame frame;
	private JPanel lastPanel;
	public void setLastPanel (JPanel panel)
	{
		this.lastPanel=panel;
	}
	public void setFrame (JFrame frame)
	{
		this.frame=frame;
	}
	/**
	 * is the constructor. it has listeners for buttons order subscription, complaint section.
	 */
	public MainGui() {
		setLayout(null);
		JButton btnOrderSubscription = new JButton("order subscription");
		btnOrderSubscription.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				SubscriptionOrder subOrder=new SubscriptionOrder();
				subOrder.getOrder();
			}
		});
		btnOrderSubscription.setBounds(384, 133, 154, 23);
		add(btnOrderSubscription);
		
		JButton btnViewSubscriptions = new JButton("view subscriptions");
		btnViewSubscriptions.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				SubscriptionOrder subOrder=new SubscriptionOrder();
				subOrder.viewOrders();
			}
		});
		btnViewSubscriptions.setBounds(384, 273, 154, 29);
		add(btnViewSubscriptions);
		
		JButton btnOrderSubscriptionFor = new JButton("order subscription for many cars");
		btnOrderSubscriptionFor.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				SubscriptionOrder subOrder=new SubscriptionOrder();
				subOrder.getOrderForManyCars();
			}
		});
		btnOrderSubscriptionFor.setBounds(294, 180, 326, 64);
		add(btnOrderSubscriptionFor);
		
		JButton btnTakeOrder = new JButton("Take order");
		btnTakeOrder.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				OneTimeOrderInAdvance subOrder=new OneTimeOrderInAdvance();
				subOrder.getOrder();
			}
		});
		btnTakeOrder.setBounds(627, 266, 100, 42);
		add(btnTakeOrder);
		
		JButton btnViewOrder = new JButton("View order");
		btnViewOrder.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				OneTimeOrderInAdvance subOrder=new OneTimeOrderInAdvance();
				subOrder.viewOrder();
			}
		});
		btnViewOrder.setBounds(198, 266, 109, 42);
		add(btnViewOrder);
		
		JLabel lblChooseAnOption = new JLabel("Choose an option");
		lblChooseAnOption.setFont(new Font("Tahoma", Font.PLAIN, 30));
		lblChooseAnOption.setBounds(354, 28, 317, 57);
		add(lblChooseAnOption);
		
		JButton btnLogout = new JButton("logout");
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				frame.setContentPane(lastPanel);
			}
		});
		btnLogout.setBounds(417, 337, 89, 23);
		add(btnLogout);
		
		JButton btnComplainSection = new JButton("Complain Section");
		btnComplainSection.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				CustomerGUI frame = new CustomerGUI();
				frame.setVisible(true);
			}
		});
		btnComplainSection.setBounds(148, 114, 135, 42);
		add(btnComplainSection);
	}
}